{include file="../../../application/admin/view/public/head" /}
<style>
    table {
        table-layout: fixed;
    }


    td {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    .layui-field-box .layui-btn{
        margin: 3px 5px;
    }
</style>
<div class="page-container p10">

    <div class="my-toolbar-box">

        <div class="left mb10">
            <fieldset class="layui-elem-field">
                <legend>{$recommend.name} - 栏目管理</legend>
                <div class="layui-field-box">
                    <form method="post" action="{:url('recommend/vodindex',['xilie_id'=>$xilie_id])}">
                        <div class="layui-form-item">
                            <label class="layui-form-label">关键词</label>
                            <div class="layui-input-inline">
                                <input type="text" name="keyword" placeholder="请输入关键词" value="{$keyword|default=''}" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-btn-inline">
                                <button type="submit" class="layui-btn layui-btn-radius">搜索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>
        </div>

        <div class="layui-btn-group">
            <a class="layui-btn layui-btn-primary j-iframe" data-href="{:url('vod/data')}?select=addInrecommend" href="javascript:;" title="添加数据"><i class="layui-icon">&#xe654;</i>添加</a>
            <a data-href="{:url('index/select')}?tab=recommend_vod&col=recommend_id&tpl=select_recommend_type&url=recommend/field" data-width="270" data-height="100" data-checkbox="1" class="layui-btn layui-btn-primary j-select"><i class="layui-icon">&#xe620;</i>移动</a>

            <a data-href="{:url('del')}" class="layui-btn layui-btn-primary j-page-btns confirm"><i class="layui-icon">&#xe640;</i>删除</a>
            {if $recommend.name==='热播综艺'}
                <a href="javascript:vodi(0);" onclick="updateZongyi()" class="layui-btn layui-btn-primary "><i class="layui-icon">&#xe640;</i>更新热播综艺</a>
            {/if}
            <a target="_blank" href="{:url('cachesetting',['xilie_id'=>$xilie_id])}" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe640;</i>批量设置缓存</a>
        </div>

    </div>


    <form class="layui-form " method="post" id="pageListForm">
        <table class="layui-table" lay-size="sm">
            <thead>
            <tr>
                <th width="25"><input type="checkbox" lay-skin="primary" lay-filter="allChoose"></th>
                <th width="40">编号</th>
                <th >名称</th>
                <th width="50">强制排序</th>
                <th width="50">默认排序</th>
                <th width="80">播放器</th>
                <th width="80">m3u8缓存</th>
                <th width="120">更新时间</th>
                <th width="200">操作</th>
            </tr>
            </thead>

            {volist name="list" id="vo"}
            <tr>
                <td><input type="checkbox" name="ids[]" value="{$vo.id}" class="layui-checkbox checkbox-ids" lay-skin="primary"></td>
                <td>{$vo.vod_id}</td>
                <td>
                     <a target="_blank" class="layui-badge-rim " href="{:mac_url_vod_detail($vo)}">{$vo.vod_name|htmlspecialchars}</a>
                    {if condition="$vo.vod_status eq 0"} <span class="layui-badge">未审</span>{/if}
                    {if condition="$vo.vod_lock eq 1"} <span class="layui-badge">锁定</span>{/if}
                    {if condition="$vo.vod_isend eq 0 && $vo.vod_serial neq ''"} <span class="layui-badge layui-bg-blue">连载{$vo.vod_serial}</span>{/if}
                    {if condition="$vo.vod_remarks neq ''"} <span class="layui-badge layui-bg-orange">{$vo.vod_remarks}</span>{/if}
                    {if condition="$vo.vod_plot eq 1"} <span class="layui-badge layui-bg-cyan">剧情</span>{/if}
                    {if condition="$vo.vod_copyright eq 1"} <span class="layui-badge layui-bg-black">版权</span>{/if}
                </td>
                <td><a data-href="{:url('index/select')}?tab=recommend_vod&col=sort_manual&tpl=select_sort&val={$vo.sort_manual}&url=recommend/field&ids={$vo.id}" data-width="270" data-height="100" class=" j-select"><span class="layui-badge layui-bg-orange">{$vo.sort_manual}</span></a></td>
                <td><a data-href="{:url('index/select')}?tab=recommend_vod&col=sort&tpl=select_sort&val={$vo.sort}&url=recommend/field&ids={$vo.id}" data-width="270" data-height="100" class=" j-select"><span class="layui-badge layui-bg-orange">{$vo.sort}</span></a></td>
                <td><span title="{$vo.vod_play_from|str_replace='$$$',',',###}-{$vo.vod_down_from|str_replace='$$$',',',###}">{$vo.vod_play_from|str_replace='$$$',',',###}-{$vo.vod_down_from|str_replace='$$$',',',###}</span></td>
                <td>{$vo.is_cache==1?'<font color="red">已缓存</font>':''}</td>
                <td>{$vo.vod_time|mac_day=color}</td>
                <td>
                    <a class="layui-badge-rim j-iframe" data-full="1" data-href="{:url('explore/tuisong?id='.$vo['vod_id'])}" href="javascript:;" data-title="推送">推送</a>
                    <a class="layui-badge-rim" target="_blank" href="http://video.app.bucuo.online/index.php/explore/m3u8?id={$vo['vod_id']}&access=bucuo" href="javascript:;" data-title="标记m3u8">标记m3u8</a>
                    <a class="layui-badge-rim j-iframe" data-full="1" data-href="{:url('vod/info?id='.$vo['vod_id'])}" href="javascript:;" title="编辑">编辑</a>
                    <a class="layui-badge-rim j-tr-del" data-href="{:url('del?ids='.$vo['id'])}" href="javascript:;" title="删除">删除</a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div id="pages" class="center"></div>
    </form>
</div>




{include file="../../../application/admin/view/public/foot" /}

<script type="text/javascript">
    var curUrl="{:url('recommend/vodindex',$param)}";
    layui.use(['laypage', 'layer','form'], function() {
        var laypage = layui.laypage
                , layer = layui.layer,
                form = layui.form;

        laypage.render({
            elem: 'pages'
            ,count: {$total}
            ,limit: {$limit}
            ,curr: {$page}
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            ,jump: function(obj,first){
                if(!first){
                    location.href = curUrl.replace('%7Bpage%7D',obj.curr).replace('%7Blimit%7D',obj.limit);
                }
            }
        });

        document.querySelector('#deleterecommend').addEventListener('click',function (ret){
            var dataset = ret.currentTarget.dataset
            console.log(dataset);
            var item = JSON.parse(dataset.item);
            if(confirm('确定要删除主题《'+ item.name+'》吗?')){
                $.ajax({
                    url:'{:url("deleterecommend")}',
                    data:{
                        xilie_id:item.id
                    },
                    type:'post',
                    dataType: 'json'
                }).done(function (ret){
                    alert(ret.msg);
                    if (ret.code===1){
                        location.reload();
                    }
                })
            }
        })

    });
    function addInrecommend(obj){
        var ids =[];
        $(obj).each(function(index, item) {
            if(item.checked){
                    ids[ids.length] = item.value;
            }
        });
        $.ajax({
            url:"",
            type:'post',
            dataType:'json',
            url:'{:url("recommend/addInrecommend")}',
            data:{
                id:'{$xilie_id}',
                vod_ids:ids
            }
        }).done(function (ret){
            console.log(ret);
            // location.reload();
            if(ret.code==1){
                location.reload();
            }else{
                alert(ret.msg);
            }
        })

    }
    function updateZongyi(){
        $.ajax({
            url:"",
            type:'post',
            dataType:'json',
            url:'{:url("recommend/updateZongyi")}',
            data:{

            }
        }).done(function (ret){
            console.log(ret);
            // location.reload();
            if(ret.code==1){
                location.reload();
            }else{
                alert(ret.msg);
            }
        })
    }

</script>
</body>
</html>